/***************************************************************************\
 * Copyright (C) by Keio University
 * CalibrationMatrix.hpp created in 12 2011.
 * Mail : fdesorbi@hvrl.ics.keio.ac.jp
 *
 * CalibrationMatrix.hpp is part of the HVRL Engine Project.
 *
 * The HVRL Engine Project is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * The HVRL Engine Project is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
\***************************************************************************/

#ifndef COMPUTER_VISION__CALIBRATION_MATRIX_HPP__
#define COMPUTER_VISION__CALIBRATION_MATRIX_HPP__

#include "hvrl/common/Common.hpp"

#include <opencv2/opencv.hpp>


namespace hvrl
{

class CalibrationMatrix
{

public:
	CalibrationMatrix(void);
	CalibrationMatrix(const cv::Mat& P) throw(Exception);
	CalibrationMatrix(const cv::Mat& K, cv::Mat& T) throw(Exception);
	~CalibrationMatrix(void);

	// Accessors
	cv::Mat getIntrinsic(void) const { return this->K; }
	cv::Mat getExtrinsic(void) const { return this->T; }
	cv::Mat getRotation(void) const { return this->R; }
	cv::Mat getTranslation(void) const { return this->t; }
	cv::Mat getCenter(void) const { return this->C; }

private:
    void inverseKT(void);
    void extractRtC(void);

private:
    cv::Mat P;
	cv::Mat K;
	cv::Mat T;
	cv::Mat R;
	cv::Mat t;
	cv::Mat C;

	cv::Mat K_inverse;
	cv::Mat T_inverse;
	cv::Mat R_inverse;



};

}

#endif
